package top.coolrainly.module.resource.dal.mysql.group;

import java.util.*;

import top.coolrainly.framework.common.pojo.PageResult;
import top.coolrainly.framework.mybatis.core.query.LambdaQueryWrapperX;
import top.coolrainly.framework.mybatis.core.mapper.BaseMapperX;
import top.coolrainly.module.resource.dal.dataobject.content.ResourceContentDO;
import top.coolrainly.module.resource.dal.dataobject.group.ResourceGroupDO;
import org.apache.ibatis.annotations.Mapper;
import top.coolrainly.module.resource.controller.admin.group.vo.*;

/**
 * Web3D 资源 分组 Mapper
 *
 * @author CoolRainLy
 */
@Mapper
public interface ResourceGroupMapper extends BaseMapperX<ResourceGroupDO> {

    default PageResult<ResourceGroupDO> selectPage(ResourceGroupPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ResourceGroupDO>()
                .likeIfPresent(ResourceGroupDO::getName, reqVO.getName())
                .eqIfPresent(ResourceGroupDO::getParent, reqVO.getParent())
                .eqIfPresent(ResourceGroupDO::getType, reqVO.getType())
                .eqIfPresent(ResourceGroupDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ResourceGroupDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResourceGroupDO::getId));
    }

    default List<ResourceGroupDO> selectListByType(Integer type) {
        LambdaQueryWrapperX<ResourceGroupDO> queryWrapperX = new LambdaQueryWrapperX<>();
        if (Objects.nonNull(type)) {
            queryWrapperX.eq(ResourceGroupDO::getType, type);
        }
        return selectList(queryWrapperX);
    }

}